<script setup lang="ts">
import { storeToRefs } from 'pinia'
import { reactive, computed, watch } from 'vue'
import FinanceMultiLineForMeeter from '@/components/Echart/line/FinanceMultiLineForMeeter.vue'
import { useFinanceStore } from '@/stores/module/finance'
import { headersStore } from '@/stores/apiHeader'
import { useDialogStore } from '@/stores/dialog'
const dialogStore = useDialogStore()
const { dialogInfo } = dialogStore
const dialogInfoVisible = dialogInfo.visible
const financeStore = useFinanceStore() // 创建store实例
const { getVariableExpensesWages, getEveryVariableExpensesWages }: any =
  storeToRefs(financeStore)
// 区分全球区域对比或国家对比  0各个区域，1 各个国家 默认空
const data = computed(() => {
  return headersStore().every_code === ''
    ? getVariableExpensesWages.value
    : getEveryVariableExpensesWages.value
})

const options = reactive({
  name: 'VariableExpensesWages',
  xAxis: {
    data: data.value.sub_titles,
  },
  data: data.value.info,
})
watch(
  () => data.value,
  () => {
    // 重新赋值options.data
    options.data.splice(0, options.data.length, ...data.value.info)
    options.xAxis.data.splice(
      0,
      options.xAxis.data.length,
      ...data.value.sub_titles
    )
  },
  { deep: true }
)
</script>
<template>
  <card-box componentName="VariableExpensesWages">
    <template v-slot:title v-if="data.title">
      <h1
        :class="{
          subtitle: dialogInfoVisible,
        }"
      >
        {{ data.title }}
      </h1>
    </template>
    <FinanceMultiLineForMeeter :chart-data="options" v-if="data.info.length" />
    <div v-else class="default-img">
      <p>{{ $t('bi_common_nodata') }}</p>
    </div>
  </card-box>
</template>
<style lang="scss" scoped>
.default-img {
  width: 100%;
  text-align: center;
  padding: 120px 0;
  background-image: url('@/assets/images/canvsimage/default.png');
  background-repeat: no-repeat;
  background-position: center;

  font-size: 16px;
  color: #00f6ff;
}
.subtitle {
  font-size: 30px;
}
</style>
